<script setup lang="ts">
import { ref, onMounted } from 'vue'
import {
  getInfraredSetDataApi
} from '@/api/infrared'
// props

const targetColor = ref('')

// 定义函数

onMounted( () => {
  getColor()
})

// 获取颜色配置选项
const getColor = async () => {
  let res:any = await getInfraredSetDataApi()
  targetColor.value = res.color
}

// 选择颜色域
const chooseColor = (num:string) => {
  targetColor.value = num
}

defineExpose({
  targetColor
})
</script>

<template>
  <div class="color-config">
    <!-- <ColorPicker /> -->
    <div class="color-item-box">
      <div
        class="color-item"
        @click="chooseColor('0')"
      >
        <img
          src="../assets/bckImg/color0.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('1')"
      >
        <img
          src="../assets/bckImg/color1.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('2')"
      >
        <img
          src="../assets/bckImg/color2.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('3')"
      >
        <img
          src="../assets/bckImg/color3.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('4')"
      >
        <img
          src="../assets/bckImg/color4.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('5')"
      >
        <img
          src="../assets/bckImg/color5.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('6')"
      >
        <img
          src="../assets/bckImg/color6.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('7')"
      >
        <img
          src="../assets/bckImg/color7.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('8')"
      >
        <img
          src="../assets/bckImg/color8.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('9')"
      >
        <img
          src="../assets/bckImg/color9.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('10')"
      >
        <img
          src="../assets/bckImg/color10.png"
          alt=""
        >
      </div>
      <div
        class="color-item"
        @click="chooseColor('11')"
      >
        <img
          src="../assets/bckImg/color11.png"
          alt=""
        >
      </div>
    </div>
    <div class="target-title">
      已选颜色域：
    </div>
    <div class="target-color">
      <img
        v-if="targetColor === '0'"
        src="../assets/bckImg/color0.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '1'"
        src="../assets/bckImg/color1.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '2'"
        src="../assets/bckImg/color2.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '3'"
        src="../assets/bckImg/color3.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '4'"
        src="../assets/bckImg/color4.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '5'"
        src="../assets/bckImg/color5.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '6'"
        src="../assets/bckImg/color6.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '7'"
        src="../assets/bckImg/color7.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '8'"
        src="../assets/bckImg/color8.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '9'"
        src="../assets/bckImg/color9.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '10'"
        src="../assets/bckImg/color10.png"
        alt=""
      >
      <img
        v-else-if="targetColor === '11'"
        src="../assets/bckImg/color11.png"
        alt=""
      >
      <div v-else>
        暂无
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.color-config {
      width: 220px;
      height: 236px;
      margin-top: 10px;
      margin-left: 20px;

      /* border: 1px solid red; */
      .color-item-box {
        width: 220px;
        height: 176px;
        overflow: auto;

        /* border: 1px solid blue; */
        .color-item {
          width: 220px;
          height: 25px;
          margin-top: 5px;
          background-repeat: no-repeat;
          background-position: 0 0;

          /* border: 1px solid blue; */
          >img {
            width: 25px;
            height: 220px;
            margin-top: -97px;
            margin-left: 96px;

            /* border: 1px solid red; */
            transform: rotate(-90deg);
          }
        }
        .color-item:hover {
          border: 2px solid red;
        }
      }
      .color-item-box::-webkit-scrollbar {
        display: none;
      }
      .target-title {
        width: 100px;
        height: 20px;
        margin-top: 15px;
        color: #4e5969;
        font-weight: 500;
        font-size: 14px;
        font-family: PingFang,sans-serif;
        line-height: 16px;
        background-clip: text;

        /* border: 1px solid blue; */
      }
      .target-color {
          width: 220px;
          height: 25px;
          margin-top: 5px;
          background-repeat: no-repeat;
          background-position: 0 0;

          /* border: 1px solid blue; */
          >img {
            width: 25px;
            height: 220px;
            margin-top: -97px;
            margin-left: 96px;

            /* border: 1px solid red; */
            transform: rotate(-90deg);
          }
        }
    }
</style>